# -*- coding: utf-8 -*-
# 创建时间：2021/8/9 15:53
from bs4 import BeautifulSoup
import requests
import time, math, random, json
import pymysql
import re
from hhy import FileUtil,DateUtil,ToolUtil,HttpUtil
from selenium import webdriver
__author__ = 'LuckyHhy'


def get_content(url):
    headers = {"User-Agent": HttpUtil.AgentRandom()}
    A = requests.session()  # 用一个会话请求
    A.headers = headers
    cont = A.get(url, timeout=20, allow_redirects=False)
    soup = BeautifulSoup(cont.text, 'html.parser')
    page_text = soup.find(class_="article-content").find_all("p")

    with open('p.txt', 'a', encoding='utf-8') as f:
         f.write(str(page_text))



def main():
    url='https://www.cbf.com.br/pelo-mundo/noticias/index/em-casa-internacional-decide-seu-destino-na-conmebol-libertadores-con'
    #run_main(url)
    get_content(url)
    pass


if __name__ == '__main__':
    main()
